# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm64/configs/pinenote_defconfig
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=linux-pine64-pinenote
pkgver=6.12.0
pkgrel=0
pkgdesc="Pine64 PineNote close to mainline fork"
arch="aarch64"
_carch="arm64"
_flavor="pine64-pinenote"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="
	bash
	bc
	bison
	findutils
	flex
	openssl-dev
	perl
"

# Source
_config="config-$_flavor.$arch"
_commit="9d066a65f5cbaa8cd3bfc73a1b54fbac2d0f76ac"
source="
	$pkgname-$_commit.tar.gz::https://github.com/m-weigand/linux/archive/$_commit.tar.gz
	$_config
"
builddir="$srcdir/linux-$_commit"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$CARCH" .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}

package() {
	mkdir -p "$pkgdir"/boot

	install -Dm644 "$builddir/arch/$_carch/boot/Image" \
		"$pkgdir/boot/vmlinuz"

	make modules_install dtbs_install \
		ARCH="$_carch" \
		INSTALL_PATH="$pkgdir"/boot/ \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs
	rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source

	install -D "$builddir"/include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}

sha512sums="
d3c2510f9f835a0570fbb812cec2f9e12e402878c1f9f214364ae1918bc4c00f69a1fc5e005cf6b85c0690e6fd5f6ce9e61efd88145a83725ed12b6b8c07b97e  linux-pine64-pinenote-9d066a65f5cbaa8cd3bfc73a1b54fbac2d0f76ac.tar.gz
99294bd6c53b1cf3832addbc80ea23b9089bb03463e2a9ebe93ab5feb1b2ff9ee38f158032705429230765bae2df23bb3401ec14902134c80d9dd6e58e188be5  config-pine64-pinenote.aarch64
"
